From b2595c847ca17df6858a7f90dc2a73e13c25a9c6 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Fri, 2 Sep 2005 01:54:45 +0000 Subject: [PATCH] Keep track of cursor position also in root window coordinates. Prune out 2005-09-02 Tor Lillqvist * gdk/win32/gdkevents-win32.c (gdk_event_translate): Keep track of cursor position also in root window coordinates. Prune out superfluous WM_MOUSEMOVE messages even earlier, based on root window coordinates. Windows sends WM_MOUSEMOVE messages after a new window has ben mapped below the cursor even if the mouse doesn't move. We used to generate GDK_MOTION_NOTIFY in these cases. This confused at least gtk_menu_motion_notify(). (#314995) * gtk/gtkintl.h: No need to include config.h here. It caused warnings about GTK_LOCALEDIR being redefined on Win32 when compiling files where gtkintl.h is included after gtkprivate.h (which #undefines and re-#defines GTK_LOCALEDIR on Win32). * gtk/gtkplug.c: Include config.h. --- ChangeLog | 17 +++++++++++++++++ ChangeLog.pre-2-10 | 17 +++++++++++++++++ gdk/win32/gdkevents-win32.c | 25 ++++++++++++++----------- gtk/gtkintl.h | 1 - gtk/gtkplug.c | 2 ++ 5 files changed, 50 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 129fbb0cb6..bb88c89fca 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2005-09-02 Tor Lillqvist + + * gdk/win32/gdkevents-win32.c (gdk_event_translate): Keep track of + cursor position also in root window coordinates. Prune out + superfluous WM_MOUSEMOVE events even earlier, based on root window + coordinates. Windows sends WM_MOUSEMOVE messages after a new + window has ben mapped below the cursor even if the mouse doesn't + move. We used to generate GDK_MOTION_NOTIFY in these cases. This + confused at least gtk_menu_motion_notify(). (#314995) + + * gtk/gtkintl.h: No need to include config.h here. It caused + warnings about GTK_LOCALEDIR being redefined on Win32 when + compiling files where gtkintl.h is included after gtkprivate.h + (which #undefines and re-#defines GTK_LOCALEDIR on Win32). + + * gtk/gtkplug.c: Include config.h. + 2005-09-01 Matthias Clasen * gtk/gtkfilesystemunix.c: Pass statbufs down to diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 129fbb0cb6..bb88c89fca 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,20 @@ +2005-09-02 Tor Lillqvist + + * gdk/win32/gdkevents-win32.c (gdk_event_translate): Keep track of + cursor position also in root window coordinates. Prune out + superfluous WM_MOUSEMOVE events even earlier, based on root window + coordinates. Windows sends WM_MOUSEMOVE messages after a new + window has ben mapped below the cursor even if the mouse doesn't + move. We used to generate GDK_MOTION_NOTIFY in these cases. This + confused at least gtk_menu_motion_notify(). (#314995) + + * gtk/gtkintl.h: No need to include config.h here. It caused + warnings about GTK_LOCALEDIR being redefined on Win32 when + compiling files where gtkintl.h is included after gtkprivate.h + (which #undefines and re-#defines GTK_LOCALEDIR on Win32). + + * gtk/gtkplug.c: Include config.h. + 2005-09-01 Matthias Clasen * gtk/gtkfilesystemunix.c: Pass statbufs down to diff --git a/gdk/win32/gdkevents-win32.c b/gdk/win32/gdkevents-win32.c index e73fdc508c..89dc4c8576 100644 --- a/gdk/win32/gdkevents-win32.c +++ b/gdk/win32/gdkevents-win32.c @@ -140,6 +140,7 @@ GPollFD event_poll_fd; static GdkWindow *current_window = NULL; static gint current_x, current_y; +static gint current_root_x, current_root_y; static UINT msh_mousewheel; static UINT client_message; @@ -2731,6 +2732,17 @@ gdk_event_translate (MSG *msg, msg->wParam, GET_X_LPARAM (msg->lParam), GET_Y_LPARAM (msg->lParam))); + /* If we haven't moved, don't create any GDK event. Windows + * sends WM_MOUSEMOVE messages after a new window is shows under + * the mouse, even if the mouse hasn't moved. This disturbs gtk. + */ + if (msg->pt.x + _gdk_offset_x == current_root_x && + msg->pt.y + _gdk_offset_y == current_root_y) + break; + + current_root_x = msg->pt.x + _gdk_offset_x; + current_root_y = msg->pt.y + _gdk_offset_y; + assign_object (&window, find_window_for_mouse_event (window, msg)); if (p_grab_window != NULL) @@ -2757,15 +2769,6 @@ gdk_event_translate (MSG *msg, if (window != orig_window) translate_mouse_coords (orig_window, window, msg); - /* If we haven't moved, don't create any event. - * Windows sends WM_MOUSEMOVE messages after button presses - * even if the mouse doesn't move. This disturbs gtk. - */ - if (window == current_window && - GET_X_LPARAM (msg->lParam) == current_x && - GET_Y_LPARAM (msg->lParam) == current_y) - break; - event = gdk_event_new (GDK_MOTION_NOTIFY); event->motion.window = window; event->motion.time = _gdk_win32_get_next_tick (msg->time); @@ -2774,8 +2777,8 @@ gdk_event_translate (MSG *msg, _gdk_windowing_window_get_offsets (window, &xoffset, &yoffset); event->motion.x += xoffset; event->motion.y += yoffset; - event->motion.x_root = msg->pt.x + _gdk_offset_x; - event->motion.y_root = msg->pt.y + _gdk_offset_y; + event->motion.x_root = current_root_x; + event->motion.y_root = current_root_y; event->motion.axes = NULL; event->motion.state = build_pointer_event_state (msg); event->motion.is_hint = FALSE; diff --git a/gtk/gtkintl.h b/gtk/gtkintl.h index 3e03c69ce9..4b176bd9f6 100644 --- a/gtk/gtkintl.h +++ b/gtk/gtkintl.h @@ -1,7 +1,6 @@ #ifndef __GTKINTL_H__ #define __GTKINTL_H__ -#include "config.h" #include #ifdef ENABLE_NLS diff --git a/gtk/gtkplug.c b/gtk/gtkplug.c index 4b6271c329..a0403c2bcb 100644 --- a/gtk/gtkplug.c +++ b/gtk/gtkplug.c @@ -25,6 +25,8 @@ * GTK+ at ftp://ftp.gtk.org/pub/gtk/. */ +#include + #include "gtkmain.h" #include "gtkmarshalers.h" #include "gtkplug.h" -- 2.30.2